/**
    * 虚拟登录  
    * @/views/budget/virtualLogin
    * 2020-9-7
    * zengfx
 */
<template>
  <div class="virtualLogin_container" v-loading="showAllLoading"></div>
</template>

<script>
import { getRequestParams } from "@/common/js/fastInquiryFn2";
import { setCookie, delCookie } from "@/common/js/cookie";
import { setSessionStorage } from "@/common/js/storage";
import { $loginAPI } from "@/api";
export default {
  data() {
    return {
      showAllLoading: true,
      param: null,
    };
  },
  methods: {
    handle_virtualLogin() {
      let param = {
        phone: this.param.phone,
        uuid: this.param.uuid,
      };
      $loginAPI.eipLogin(
        { phone: this.param.phone, uuid: this.param.uuid },
        (res) => {
          if (res.code == 0) {
            // 保存token
            setCookie("token", res.content.token);
            setSessionStorage("accountInfo", res.content.userInfo);
            window.sessionStorage.setItem("SysUserCode", this.param.phone);
            window.sessionStorage.setItem("userName", res.content.userName);
            window.sessionStorage.setItem('eip', true);
            this.showAllLoading = false;
            res.content.userInfo.roleId == 5 ? this.$router.push({ path: "/dashboard/index" }) : this.$router.push({ path: "/budget/dashboard" });
            // this.$router.push({ path: "/budget/home" });
          } else {
            this.showAllLoading = false;
            this.$message.error(res.message);
            this.$router.push({ path: "/login" });
          }
        },
        (err) => {
          this.showAllLoading = false;
          this.$router.push({ path: "/login" });
        }
      );
    },
  },
  created() {
    this.param = getRequestParams();
    // this.param = window.zjhc;
    console.log(this.param.phone);
    this.$nextTick(() => {
      this.handle_virtualLogin();
    });
  },
};
</script>

<style lang="scss" scoped>
.virtualLogin_container {
  width: 100%;
  height: 100%;
}
</style>